/* __placeholder__ */
export default (await import('vue')).defineComponent({
name: "TestS011",
components: {},
data() {
return {
form: {},
dialogVisible: false,
data011: "哈哈",
data012: [
{ id: "1", name: "1" },
{ id: "2", name: "2" },
{ id: "3", name: "3" },
{ id: "4", name: "4" },
],
data013: "",
data014: "",
show011: true,

tableData: [
{ "id": "1", "username": "aaa", "password": "123456" },
{ "id": "2", "username": "bbb", "password": "sddds" },
{ "id": "3", "username": "ccc", "password": "sdsds" },
{ "id": "4", "username": "ddd", "password": "sdsdf" },
{ "id": "5", "username": "eee", "password": "sfdfdg" },
],
rules: {
username: [
{ required: true, message: '用户名不能为空', trigger: 'blur' },
{ min: 3, max: 5, message: '长度在 3 到 5 个字符', trigger: 'blur' },
{ pattern: /\d/, message: '用户名必须包含数字', trigger: 'blur' }
]
}
};
},
mounted() {
},
methods: {
test011() {
},
edithandler(index, rows) {
this.form = rows[index];
this.dialogVisible = true;
},
test013() {
console.log(this.data013);
},
test014() {
this.data013 = "哈哈哈";
},
deleteRow(index, rows) {
rows.splice(index, 1);
},
savehandler() {

var userName = this.form.username;
if (this.findUser(userName)) {
this.$message.error('错了哦，用户名' + userName + '已存在！');
} else {
this.tableData.push(this.form);
}

this.form = {};
this.dialogVisible = false;
console.log(this.findUser(this.form.username));

},
findUser(username) {
var result = false;
for (var item of this.tableData) {
if (item.username == username) {
result = true;
break;
}
}
return result;
}
}
});
